<template>
    <div>
        <div class="container">
            <el-page-header @back="goBack" content="打包站收货单详情"></el-page-header>

            <!-- 简要信息 -->
            <el-descriptions class="e-m-t-45" :column="2" title="简要信息" border :labelStyle="{width:'120px'}">
                <el-descriptions-item label="编号">{{form.number}}</el-descriptions-item>
                <el-descriptions-item label="状态">
                    <span class="color-success" v-if="form.state == '已出库'">{{form.state}}</span>
                    <span class="color-success" v-if="form.state == '已完结'">{{form.state}}</span>
                    <span class="color-danger" v-if="form.state == '已取消'">{{form.state}}</span>
                </el-descriptions-item>
                <el-descriptions-item label="运送小哥">{{form.brother.name}}</el-descriptions-item>
                <el-descriptions-item label="完结时间">{{form.endtime}}</el-descriptions-item>
                <el-descriptions-item label="出库总数量">{{form.weight}}KG/{{ form.quantity }}件</el-descriptions-item>
                <el-descriptions-item label="出库总价值">{{form.amount}}元</el-descriptions-item>
                <el-descriptions-item label="差额值" v-if="form.state == '已完结'">{{form.weightdifference}}KG/{{ form.quantitydifference }}件</el-descriptions-item>
                <el-descriptions-item label="对比差额" v-if="form.state == '已完结'">
                    <el-tag type="danger" v-if="form.isexception">大差额</el-tag>
                    <el-tag type="success" v-else>正常</el-tag>
                </el-descriptions-item>
                <el-descriptions-item label="审查" v-if="form.state == '已完结'">
                    <el-tag v-if="form.examinestate == '已审核'" type="success">已审核</el-tag>
                    <el-button v-else type="primary" @click="examine">未审核</el-button>
                </el-descriptions-item>
                <el-descriptions-item label="接收打包站">{{form.packstation.name}}</el-descriptions-item>
                <el-descriptions-item label="审核人" v-if="form.state == '已完结'">{{ form.examinename || '--' }}</el-descriptions-item>
                <el-descriptions-item label="出库备注" span="2" v-if="form.remarks">{{form.remarks}}</el-descriptions-item>
            </el-descriptions>
            <!-- /简要信息 -->

            <!-- 打包站收货总览 -->
            <template v-if="dataarr.length > 0">
                <h4>打包站收货总览</h4>
                <div class="flex">
                    <div class="e-flex-1">
                        <el-table :data="dataarr" :span-method="objectSpanMethod2" show-summary :summary-method="getSummaries" stripe border style="width: 100%">
                            <el-table-column
                                prop="large"
                                label="类型"
                                width="200">
                            </el-table-column>
                            <el-table-column
                                prop="typenames"
                                label="小类"
                                >
                            </el-table-column>
                            <el-table-column
                                prop="price"
                                label="单价(元/KG)"
                                width="200">
                                <template slot-scope="scope">
                                    <span>{{ scope.row.price }}{{ scope.row.isweighing?'元/KG':'元/件' }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column
                                prop="weight"
                                label="出库数量"
                                width="200">
                                <template slot-scope="scope">
                                    <span>{{ scope.row.weight }}kg/{{ scope.row.quantity }}件</span>
                                </template>
                            </el-table-column>
                            <el-table-column
                                prop="amount"
                                label="总价"
                                width="200">
                                <template slot-scope="scope">
                                    <span>{{ scope.row.amount }}元</span>
                                </template>
                            </el-table-column>
                            <el-table-column
                                prop="typeremarks"
                                label="备注"
                                width="200">
                                <template slot-scope="scope">
                                    <span>{{ scope.row.typeremarks }}</span>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>
                </div>
            </template>
            <!-- /打包站收货总览 -->

            <!-- 查看站点出库明细 -->
            <h4>查看站点出库明细（共有{{form.store.length}}个）</h4>
            <el-collapse v-model="activeNames">
                <el-collapse-item
                    v-for="(item, index) in form.store" :key="index"
                    :name="index">
                    <template slot="title">
                        <div class="u-flex">
                            <span class="e-font-16">站点名称：{{item.store.name}}<span class="tips e-font-14">(出库量：{{item.weight}}KG/{{item.quantity}}件)</span></span>
                            <span class="u-flex-1"></span>
                            <span class="color-success" v-if="item.state == '已出库'">{{item.state}}</span>
                            <span class="color-danger" v-else>{{item.state}}</span>
                        </div>
                        <!-- <div>
                            <span>出库总价值：{{ item.amount }}元</span>
                        </div> -->
                    </template>
                    <!-- 表格数据 -->
                    <h3>站点出库总览</h3>
                    <el-descriptions :column="2" border :labelStyle="{width:'120px'}">
                        <el-descriptions-item label="出库店员">{{item.staff.name}}</el-descriptions-item>
                        <el-descriptions-item label="出库时间">{{item.delivertime}}</el-descriptions-item>
                        <el-descriptions-item label="出库总数量">{{item.weight}}KG/{{item.quantity}}件</el-descriptions-item>
                        <el-descriptions-item label="出库总价值">{{item.sellamount}}元</el-descriptions-item>
                    </el-descriptions>
                    <h3>出库明细</h3>
                    <el-table :data="form.store[index].formatDelivers" :span-method="objectSpanMethod" stripe border style="width: 100%" class="e-m-t-10">
                        <el-table-column
                            prop="large"
                            label="类型"
                            >
                        </el-table-column>
                        <el-table-column
                            prop="typenames"
                            label="可回收物"
                            >
                        </el-table-column>
                        <el-table-column
                            prop="price"
                            label="单价"
                            >
                        </el-table-column>
                        <el-table-column
                            prop="weight"
                            label="数量"
                            width="200">
                            <template slot-scope="scope">
                                <span>{{ scope.row.weight }}{{ scope.row.isweighing?'KG':'件' }}</span>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="amount"
                            label="总价"
                            width="200">
                            <template slot-scope="scope">
                                <span>{{ scope.row.amount }}元</span>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="typeremarks"
                            label="备注"
                            width="200">
                            <template slot-scope="scope">
                                <span>{{ scope.row.typeremarks || '--' }}</span>
                            </template>
                        </el-table-column>
                    </el-table>
                    <!-- 上传的图片 -->
                    <div class="images-list e-m-t-15">
                        <div class="item" v-for="(item, index) in item.proves" :key="index">
                            <el-image
                                style="width: 150px; height: 150px; border-radius: 6px;"
                                :src="fileURL + item"
                                :preview-src-list=[[fileURL+item]]
                                fit="cover"></el-image>
                        </div>
                    </div>
                </el-collapse-item>
            </el-collapse>
            <!-- /查看各站点出库明细 -->

            <!-- 已出库时的表单操作 -->
            <template v-if="form.state == '已出库'">
                <h4>出库回执录入</h4>
                <!-- <el-button type="primary" icon="el-icon-plus" plain @click="dialogVisible = true">添加品类</el-button> -->
                <select-product 
                    :multiple="true"
                    :btnStyle="2"
                    v-model="chooseType"
                    @confirmSelect="handleProductSelect"
                    placeholder="点击选择可回收物"
                    dialog-title="请选择可回收物"
                    style="width: 315px;">
                </select-product>

                <el-table
                    ref="multipleTable"
                    tooltip-effect="dark"
                    :data="stockList"
                    :span-method="stockListSpanMethod"
                    stripe
                    border
                    style="width: 100%; margin-top: 20px"
                >
                    <el-table-column prop="large" label="类型" width="200">
                        <template slot-scope="scope">
                            <h4 class="text-center">{{ scope.row.largeName }}({{ scope.row.isweighing?'KG':'件' }})</h4>
                        </template>
                        </el-table-column>
                        <el-table-column prop="name" label="小类" width="200">
                        </el-table-column>
                        <el-table-column label="单价" width="200">
                            <template slot-scope="scope">
                                <el-input type="number" v-model="scope.row.price" placeholder="请填写单价"></el-input>
                            </template>
                        </el-table-column>
                        <el-table-column label="出库重量/数量" width="200">
                        <template slot-scope="scope">
                            <el-input type="number" v-model="scope.row.weight" placeholder="请填写出库数量"></el-input>
                        </template>
                    </el-table-column>
                    <el-table-column label="备注">
                        <template slot-scope="scope">
                            <el-input type="text" v-model="scope.row.remarks" placeholder="请填写备注"></el-input>
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" width="200">
                        <template slot-scope="scope">
                            <el-button type="danger" size="mini" @click="delRow(scope.$index, scope.row)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>

                <h4>上传回执单</h4>
                <div class="images-list e-m-t-30">
                    <div class="item" v-for="(item, index) in confirmEnd.proves" :key="index">
                        <el-image style="width: 150px; height: 150px; border-radius: 6px;" :src="fileURL + item"
                        :preview-src-list=[[fileURL+item]] fit="cover"></el-image>
                        <span class="el-icon-error err" @click.stop="delFile(index)"></span>
                    </div>
                    <div class="item">
                        <cropper-upload @getUpload="handleFilesSuccess" class="avatar-uploader">
                            <div class="avatar-uploader-icon">
                                <div><i class="el-icon-plus"></i></div>
                            </div>
                        </cropper-upload>
                    </div>
                </div>
            </template>
            <!-- /已出库时的表单操作 -->
            <template v-if="form.state == '已完结'">
                <h4>查看上传的回执单</h4>
                <div class="images-list e-m-t-30">
                    <div class="item" v-for="(item, index) in form.proves" :key="index">
                        <el-image style="width: 150px; height: 150px; border-radius: 6px;" :src="fileURL + item"
                        :preview-src-list=[[fileURL+item]] fit="cover"></el-image>
                    </div>
                </div>
            </template>
            <el-form label-width="0" class="e-m-t-45">
                <el-form-item>
                    <el-button @click="goBack">返回</el-button>
                    <el-button type="danger" v-if="form.state == '已出库'" @click="dialogVisible2 = true">取消</el-button>
                    <el-button type="primary" @click="deliverStore" v-if="form.state == '已出库'">完结订单</el-button>
                </el-form-item>
            </el-form>
        </div>

        <el-dialog
            title="添加品类"
            :visible.sync="dialogVisible"
            width="500px"
            >
            <div>
                <el-cascader-panel
                    class="e-w-360"
                    v-model="chooseType"
                    ref="chooseType"
                    placeholder="请选择品类"
                    separator="-"
                    @change="SelectType"
                    filterable
                    :props="{
                        lazy: true,
                        lazyLoad: loadType,
                        label: 'name',
                        value: 'id',
                        multiple: true
                    }"
                    >
                </el-cascader-panel>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取消</el-button>
                <el-button type="primary" @click="confirmSelect">确定</el-button>
            </span>
        </el-dialog>

        <!-- 取消出库订单 -->
        <el-dialog
            title="取消出库订单"
            :visible.sync="dialogVisible2"
            width="500px"
            >
            <el-form>
                <el-form-item>
                    <el-select v-model="chooseStores" placeholder="请选择站点" clearable>
                        <el-option
                            v-for="item in form.store"
                            :key="item.store.id"
                            :label="item.store.name"
                            :value="item.store.id">
                        </el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <div class="e-p-t-10 e-p-b-10">
                <div class="tips">说明：</div>
                <div class="tips">选择站点对应取消那个站点的出库单；不选择站点提交则整个出库单取消。</div>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible2 = false">取消</el-button>
                <el-button type="primary" @click="cancalOrder">确定</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
	export default {
		layout: 'admin',
		head() {
			return {
				title: '打包站收货单详情' 
			}
		},
        props:{
            id: {
                type: Number,
                default: 0
            }
        },
		data() {
			return {
                moneyarr:[],
                dataarr:[],
                form:{
                    packstation:{},
                    brother: {},
                    deliverdetails: [],
                    delivers:{
                        name: '',
                        details: [],
                        loadingproves: [],
                        deliverproves: [],
                    },
                    // loadingproves: [],
                    // deliverproves: [],
                    endproves: [],
                    packdetails: [],
                    amount:0,
                    store:[
                        
                    ],
                    packstation:{}
                },
                activeNames: [],
                stockList: [], //录入出库回执列表
                tempLargeTypeList: [], //临时储存获取类型列表
                tempSmallTypeList: {}, //临时储存获取小类列表
                chooseType: [],
                confirmEnd:{
                    orderId: 0,
                    packDetails: [
                        // {
                        //     "largeId": 0,
                        //     "typeId": 2147483647,
                        //     "remarks": "string",
                        //     "weight": 0,
                        //     "price": 0
                        // }
                    ],
                    proves: [],
                    endTime: ""
                },
                dialogVisible: false,
                tempArr: [],
                dialogVisible2: false,
                chooseStores: null
            }
        },
        mounted() {
            this.id = this.$route.query.id
            this.getDetails(this.id)
        },
        methods: {
            getDetails(id){ //获取详情
                this.dataarr = []
                this.moneyarr = []
                this.$axios.get('/PackStation/InOrder/Details?id='+id).then((res)=>{
                    console.log(res)
                    this.form = res
                    // 格式化出库总览
                    res.details.forEach((item, index) => {
                        item.details.forEach((i, x) => {
                            let obj = {}
                            obj.amount = i.amount
                            obj.price = i.price
                            obj.typenames = i.productname
                            obj.typepath = i.typepath
                            obj.weight = i.weight
                            obj.quantity = i.quantity
                            obj.large = item.names
                            obj.bigid = item.id
                            obj.isweighing = item.isweighing
                            obj.typeremarks = i.typeremarks?i.typeremarks:'/'
                            this.dataarr.push(obj)
                        })
                    })
                    console.log('dataarr',this.dataarr)
                    // 格式化小票明细
                    // res.packdetails.forEach((item, index) => {
                    //     item.details.forEach((i, x) => {
                    //         let obj = {}
                    //         obj.amount = i.amount
                    //         obj.deductionratio = i.deductionratio
                    //         obj.deductionweight = i.deductionweight
                    //         obj.grossweight = i.grossweight
                    //         obj.number = i.number
                    //         obj.weight = i.weight
                    //         obj.price = i.price
                    //         obj.netweight = i.netweight
                    //         obj.tareweight = i.tareweight
                    //         obj.typenames = i.productname
                    //         obj.typepath = i.typepath
                    //         obj.large = item.names
                    //         obj.bigid = item.id
                    //         obj.isweighing = item.isweighing
                    //         obj.typeremarks = i.typeremarks?i.typeremarks:'/'
                    //         this.moneyarr.push(obj)
                    //     })
                    // })
                    // console.log('moneyarr',this.moneyarr)
                    // 格式化站点出库明细
                    res.store.forEach((item, index) => {
                        this.form.store[index].formatDelivers = []
                        item.details.forEach((cell,x)=>{
                            cell.details.forEach((i,y)=>{
                                let obj = {}
                                obj.typenames = i.productname
                                obj.typepath = i.typepath
                                obj.weight = i.weight
                                obj.large = cell.names
                                obj.largeId = cell.id
                                obj.isweighing = cell.isweighing
                                obj.typeremarks = i.typeremarks?i.typeremarks:'/'
                                obj.price = i.sellprice
                                obj.amount = i.sellamount
                                obj.storeId = item.store.id
                                this.form.store[index].formatDelivers.push(obj)
                            })
                        })
                    })

                    console.log('格式化后的form：',this.form)
                })
            },
            deliverStore(){ //完结收货单
                let param = {
                    "id": this.id,
                    "proves": this.confirmEnd.proves,
                    "details": this.stockList,
                    "endTime": this.utils.curDateTime(new Date())
                }
                this.$confirm('您确认要完结收货单吗?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    console.log('param',param)
                    this.$axios.post('/PackStation/InOrder/End',param).then((data)=>{
                        this.$message.success('完结打包站收货单成功');
                        this.getDetails(this.id)
                    })
                }).catch(() => {

                });
            },
            // 取消出库单
            cancalOrder(){
                // this.$prompt('请输入取消原因', '提示', {
                //     confirmButtonText: '确定',
                //     cancelButtonText: '取消',
                //     inputPattern: /^[\s\S]*.*[^\s][\s\S]*$/,
                //     inputErrorMessage: '请填写取消原因'
                // }).then(({ value }) => {
                //     this.$axios.post('/Store/OutOrder/Cancel', {
                //         id: this.id,
                //         reason: value
                //     }).then((res) => {
                //         this.$message({
                //             type: 'success',
                //             message: res.msg
                //         });
                //         this.getList()
                //     })
                // })
                console.log('chooseStores',this.chooseStores)
                // let param = {
                //     orderId: Number(this.id)
                // }
                // if(this.chooseStores > 0){
                //     param.storeId = this.chooseStores
                // }
                this.$axios.get(`/PackStation/InOrder/Cancel?orderId=${this.id}&storeId=${this.chooseStores}`).then((res) => {
                    this.$message({
                        type: 'success',
                        message: res.msg
                    });
                    this.getDetails(this.id)
                    this.dialogVisible2 = false
                })
            },
            //出库明细总览合计
            getSummaries(param) {
                const { columns, data } = param;
                const sums = [];
                columns.forEach((column, index) => {
                    if (index === 0) {
                        sums[index] = '合计';
                        return;
                    }
                    const values = data.map(item => Number(item[column.property]));

                    // console.log(this.tableData)
                    if (!values.every(value => isNaN(value))) {
                        sums[index] = values.reduce((prev, curr) => {
                            const value = Number(curr);
                            if (!isNaN(value)) {
                                return prev + curr;
                            } else {
                                return prev;
                            }
                        }, 0);
                        sums[index] += '';
                    } else {
                        sums[index] = '';
                    }

                    if (column.label == '小类') {
                        sums[index] = '/'
                    }

                    if (column.label == '数量') {
                        let weight = 0
                        let num = 0
                        data.forEach((item)=>{
                            if(item.isweighing == true){
                                weight += item.weight
                            }else{
                                num += item.weight
                            }
                        })
                        sums[index] = weight + 'kg' + '  /  ' + num + '件'
                    }

                    if (column.label == '总价') {
                        let amount = 0
                        data.forEach((item)=>{
                            amount += item.amount
                        })
                        sums[index] = amount.toFixed(2) + '元'
                    }

                    if (column.label == '备注') {
                        sums[index] = '/'
                    }

                    if (column.label == '重量/数量') {
                        let weight = 0
                        let num = 0
                        data.forEach((item)=>{
                            if(item.isweighing == true){
                                weight += item.netweight
                            }else{
                                num += item.netweight
                            }
                        })
                        sums[index] = weight + 'kg' + '  /  ' + num + '件'
                    }

                    if (column.label == '出库数量') {
                        let weight = 0
                        let num = 0
                        data.forEach((item)=>{
                            if(item.isweighing == true){
                                weight += item.weight
                            }else{
                                num += item.weight
                            }
                        })
                        sums[index] = weight + 'kg' + '  /  ' + num + '件'
                    }

                    if (column.label == '单价(元/KG)') {
                        sums[index] = '/'
                    }

                    if (column.label == '金额(元)') {
                        let amount = 0
                        data.forEach((item)=>{
                            amount += item.amount
                        })
                        sums[index] = amount.toFixed(2) + '元'
                    }
                });

                return sums;
            },
            examine(){
                //审查
                this.$confirm('是否审查此单？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.$axios.get('/PackStation/InOrder/Examine?id='+this.id).then((res)=>{
                        this.$message({
                            type: 'success',
                            message: '审查成功!'
                        });
                        this.getDetails(this.id)
                    })
                })
            },
            delRow(index,row){
                console.log('点击删除按钮',index,row)
                // this.$refs.chooseType.clearCheckedNodes()
                this.stockList.splice(index,1)
                this.chooseType.forEach((item,i)=>{
                    if(item[0] == row.largeId && item[1] == row.typeId){
                        this.chooseType.splice(i,1)
                    }
                })
                console.log(this.chooseType)
            },
            handleFilesSuccess(res, file) {
                this.confirmEnd.proves.push(res.path);
            },
            delFile(index) {
                this.confirmEnd.proves.splice(index, 1);
            },
            numberChange(e,max,id){
                // console.log(e.target.value)
            },
            stockListSpanMethod({ row, column, rowIndex, columnIndex }) {
                let mergeLength = 1;//需要进行横纵合并的列
                if (columnIndex < mergeLength) {
                    let finArray = [1, 1];
                    // 处理行数据
                    let cgname = "largeId"
                    if (rowIndex === 0 || row[cgname] !== this.stockList[rowIndex - 1][cgname]) {
                        let rowspan = 1;
                        //计算需要进行合并操作的行
                        for (let i = 0; i < this.stockList.length - 1; i++) {
                            // 只合并连续的
                            if (this.stockList[i][cgname] === row[cgname] && this.stockList[i + 1][cgname] === row[cgname]) {
                                rowspan++;
                            }
                        }
                        finArray[0] = rowspan;
                    } else {
                        finArray[0] = 0;
                    }
                    return finArray
                }
            },
            SelectType(chooseArr) { //选择品类
                console.log('已选择的品类',chooseArr)
                this.tempArr = []
                chooseArr.forEach((item)=>{
                    let obj = {
                        productId: item[1],
                        name: this.tempSmallTypeList[item[0]].find((cell)=>cell.id == item[1]).name,
                        isweighing: this.tempLargeTypeList.find((cell)=>cell.id == item[0]).isweighing,
                        largeName: this.tempLargeTypeList.find((cell)=>cell.id == item[0]).name,
                        largeId: this.tempLargeTypeList.find((cell)=>cell.id == item[0]).id,
                        weight: null,
                        price: null,
                        // price: this.tempSmallTypeList[item[0]].find((cell)=>cell.id == item[1]).price?.packstationprice,
                        remarks: ''
                    }
                    this.tempArr.push(obj)
                })
                // 若有数据，则将已选择的品类与已选择的品类合并
                if(this.stockList.length > 0){
                    this.stockList.forEach((item,i)=>{
                        this.tempArr.forEach((cell,j)=>{
                            if(item.largeId == cell.largeId && item.typeId == cell.typeId){
                                this.tempArr[j] = item
                            }
                        })
                    })
                }
            },
            // 选择可回收物
            handleProductSelect(chooseArr) {
                console.log('已选择的品类',chooseArr)
                this.tempArr = []
                chooseArr.forEach((item)=>{
                    let obj = {
                        productId: item.id,
                        name: item.name,
                        isweighing: item.isweighing,
                        largeName: item.typenames,
                        largeId: item.typeid,
                        weight: null,
                        price: null,
                        // price: this.tempSmallTypeList[item[0]].find((cell)=>cell.id == item[1]).price?.packstationprice,
                        remarks: ''
                    }
                    this.tempArr.push(obj)
                })
                // 若有数据，则将已选择的品类与已选择的品类合并
                if(this.stockList.length > 0){
                    this.stockList.forEach((item,i)=>{
                        this.tempArr.forEach((cell,j)=>{
                            if(item.largeId == cell.largeId && item.typeId == cell.typeId){
                                this.tempArr[j] = item
                            }
                        })
                    })
                }
                this.stockList = this.tempArr
            },
            confirmSelect(){
                this.stockList = this.tempArr
                this.dialogVisible = false
            },
            loadType(node, resolve) { //加载品类
                const { level } = node;
                if (level == 0) {
                    this.$axios.get('/Waste/Type/List',{
                        pageIndex: 1,
                        pageSize: 9999,
                        pId: 0
                    }).then((res) => {
                        this.tempLargeTypeList = res
                        node = res.map(function(c) {
                            return {
                                id: c.id,
                                name: c.name,
                                leaf: level >= 1
                            }
                        });
                        resolve(node);
                    })
                } else {
                    if(level == 1){
                        this.$axios.get(`/Waste/product/List`,{
                            params:{
                                typeId: node.value
                            }
                        }).then((res) => {
                            this.tempSmallTypeList[node.value] = res
                            console.log('tempSmallTypeList',this.tempSmallTypeList)
                            node = res.map(function(c) {
                                return {
                                    id: c.id,
                                    name: c.name,
                                    leaf: level >= 1
                                }
                            });
                            resolve(node);
                        })
                    }else{
                        resolve();
                    }
                }
            },
            //合并站点分类订单
            // deliversObjectSpanMethod({ row, column, rowIndex, columnIndex }) {
            //     console.log(row, 'deliversObjectSpanMethod')
            //     let mergeLength = 1;//需要进行横纵合并的列
            //     let dataArr = this.form.delivers[0].formatDelivers
            //     if (columnIndex < mergeLength) {
            //         let finArray = [1, 1];
            //         // 处理行数据
            //         let num = 0
            //         let cgname = Object.keys(row)[7]//7是数字最后一项类型id
            //         if (rowIndex === 0 || row[cgname] !== dataArr[rowIndex - 1][cgname]) {
            //         let rowspan = 1;
            //         //   //计算需要进行合并操作的行
            //         for (let i = 0; i < dataArr.length - 1; i++) {
            //             // 只合并连续的
            //             if (dataArr[i][cgname] === row[cgname] && dataArr[i + 1][cgname] === row[cgname]) {
            //                 rowspan++;
            //             }
            //         }
            //             finArray[0] = rowspan;
            //         } else {
            //             finArray[0] = 0;
            //         }
            //         return finArray
            //     }
            // },
            //合并类型格子
            objectSpanMethod({ row, column, rowIndex, columnIndex }) {
                console.log(row,column, rowIndex, columnIndex,'objectSpanMethod')
                let mergeLength = 1;//需要进行横纵合并的列
                if (columnIndex < mergeLength) {
                    let finArray = [1, 1];
                    // 处理行数据
                    let num = 0
                    // let cgname = Object.keys(row)[7]//7是数字最后一项类型id
                    let cgname = 'large'
                    let arr = this.form.store.find((item)=>item.store.id == row.storeId).details
                    if (rowIndex === 0 || row[cgname] !== arr[rowIndex - 1][cgname]) {
                    let rowspan = 1;
                    //   //计算需要进行合并操作的行
                    for (let i = 0; i < arr.length - 1; i++) {
                        // 只合并连续的
                        if (arr[i][cgname] === row[cgname] && arr[i + 1][cgname] === row[cgname]) {
                            rowspan++;
                        }
                    }
                        finArray[0] = rowspan;
                    } else {
                        finArray[0] = 0;
                    }
                    return finArray
                }

                // let mergeLength = [0,5,6,7];//需要进行横纵合并的列,0开始
            
                // for (let j = 0; j < mergeLength.length; j++) {

                //     if (columnIndex == mergeLength[j]) {
                //         let finArray = [1, 1];
                //         // 处理行数据
                //         let cgname = Object.keys(row)[2] //合并单元格的主键依据，一般为第一列的值
                //         if (rowIndex === 0 || row[cgname] !== this.tableData[rowIndex - 1][cgname]) {
                //             let rowspan = 1;
                //             //计算需要进行合并操作的行
                //             for (let i = 0; i < this.tableData.length - 1; i++) {
                //                 // 只合并连续的
                //                 if (this.tableData[i][cgname] === row[cgname] && this.tableData[i + 1][cgname] === row[cgname]) {
                //                     rowspan++;
                //                 }
                //             }
                //             finArray[0] = rowspan;
                //         } else {
                //             finArray[0] = 0;
                //         }
                //         return finArray
                //     }
                // }
            },
            objectSpanMethod2({ row, column, rowIndex, columnIndex }) {
                // console.log(row,column, rowIndex, columnIndex,'objectSpanMethod')
                let mergeLength = 1;//需要进行横纵合并的列
                if (columnIndex < mergeLength) {
                    let finArray = [1, 1];
                    // 处理行数据
                    let num = 0
                    // let cgname = Object.keys(row)[7]//7是数字最后一项类型id
                    let cgname = 'large'
                    let arr = this.dataarr
                    if (rowIndex === 0 || row[cgname] !== arr[rowIndex - 1][cgname]) {
                    let rowspan = 1;
                    //   //计算需要进行合并操作的行
                    for (let i = 0; i < arr.length - 1; i++) {
                        // 只合并连续的
                        if (arr[i][cgname] === row[cgname] && arr[i + 1][cgname] === row[cgname]) {
                            rowspan++;
                        }
                    }
                        finArray[0] = rowspan;
                    } else {
                        finArray[0] = 0;
                    }
                    return finArray
                }
            },
            objmoney({ row, column, rowIndex, columnIndex }) {
                // console.log(rowIndex, columnIndex,'ssss')
                let mergeLength = 1;//需要进行横纵合并的列
                if (columnIndex < mergeLength) {
                    let finArray = [1, 1];
                    // 处理行数据
                    let num = 0
                    let cgname = Object.keys(row)[11]//7是数字最后一项类型id
                    if (rowIndex === 0 || row[cgname] !== this.moneyarr[rowIndex - 1][cgname]) {
                    let rowspan = 1;
                    //   //计算需要进行合并操作的行
                    for (let i = 0; i < this.moneyarr.length - 1; i++) {
                        // 只合并连续的
                        if (this.moneyarr[i][cgname] === row[cgname] && this.moneyarr[i + 1][cgname] === row[cgname]) {
                        rowspan++;
                        }
                    }
                    finArray[0] = rowspan;
                    } else {
                    finArray[0] = 0;
                    }
                    return finArray
                }
            },
            goBack() {
				this.$emit('goBack')
			},
            // deliverStore(){ //确定出库
            //     let form = {
            //         "id": this.id,
            //         "storeId": this.form.store.id,
            //         "deliverDetails": [

            //         ]
            //     }
            //     this.form.deliverdetails.map((item)=>{
            //         item.details.map((cell)=>{
            //             form.deliverDetails.push({
            //                 id: cell.typepath,
            //                 typeRemarks: cell.typeremarks,
            //                 weight: cell.weight
            //             })
            //         })
            //     })
            //     this.$confirm('您确认要出库吗?', '提示', {
            //         confirmButtonText: '确定',
            //         cancelButtonText: '取消',
            //         type: 'warning'
            //     }).then(() => {
            //         this.$axios.post('Admin/Store/Deliver',form).then((data)=>{
            //             this.$message.success('出库成功');
            //             this.getDetails(this.id)
            //         })
            //     }).catch(() => {

            //     });
            // }
        }
    }
</script>

<style lang="scss" scoped>
    .images-list{
        display: flex;
        .item{
            padding-right: 15px;
            position: relative;
            .el-icon-error{
                position: absolute;
                top: -8px;
                right: 7px;
                font-size: 22px;
                color: var(--red);
                background: #fff;
                border-radius: 50%;
                cursor: pointer;
                &:hover {
                    color: #f00;
                }
            }
        }
    }
    .pack{
        display: flex;
        align-items: center;
        .item{
            .name{
                font-size: 18px;
            }
            .text{
                color: var(--grey);
            }
        }
        .icon{
            font-size: 30px;
            padding: 0 40px;
            transform: rotate(90deg);
            color: var(--gray);
        }
    }
</style>
